home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Commodore Free 25
/
Commodore_Free_Issue_25_2008_Commodore_Computer_Club.d64
/
t.b guide 10.2
< prev
next >
Wrap
Text File
|
2023-02-26
|
12KB
|
437 lines
u
In the Beginning Chapter 10, Section 2
\Lord Ronin from Q-Link\
-------------------------
Here is where problems happen, I have
seen it and done it myself. As you
take another look at that thing I made
above. You can see that where there is
a 0 in the boxes under the numbers.
Then on the bottom row you put a 0. If
there is a 1 in the box, then you put
down the value of that box. Repeat for
the entire series. That is why under
the 64 there is a 1 in the box, and on
the bottom line there is a 64. Some of
us have wondered why the extra step.
Well when doing this off of paper. One
can make mistakes by skipping that
last step, like I said, seen it and
done it.
OK as that bottom line shows you add
up the numbers. This becomes just one
number. In this example it becomes the
number of 127. Trying not to confuse
you here, if there was a 1 in each of
the boxes, the total would be 255. Hey
have we seen that number before?
Yuppers and we will see it over again
many more times. Just keeps popping up
a lot. <G>
So then in the example from the book,
the first series had nothing in the
first row. The second series had the
stuff we saw above. The third series
has nothing on that row. How is this
written for the program? Remember I
said a while back about writing the
word Data at the end of the row? This
is why it works nice that way, you see
the way to write it down for this part
is
DATA 0, 127, 0
Based on the example above. Nothing in
the first series, 127 is the total for
the second series and 0 is the amount
for the third series, as there was
nothing on the row in that part. In
order to further this example and
idea. Book goes into the entire second
line of the balloon illustration.
ulow is sort of what it looks like in
the book.
+----+----+----+----+----+----+---+---+
Series 1:
0 0 0 0 0 0 0 1
+----+----+----+----+----+----+---+---+
^
= 1
+---+----+----+----+----+----+---+----+
Series 2:
1 1 1 1 1 1 1 1
+---+----+----+----+----+----+---+----+
^ ^ ^ ^ ^ ^ ^ ^
128 + 64 + 32 + 16 + 8 + 4 + 2 + 1
+---+----+----+----+----+----+---+----+
= 255
Series 3:
1 1 0 0 0 0 0 0
+---+----+----+----+----+----+---+----+
^ ^
128 + 64
= 192
For row 2, the data would be:
DATA 1, 255, 192
Yeah I know that it looks complicated.
But by the time you have done a couple
of these lines. You get the message
that is being applied, granted that
there are 21 lines to do of three
series each. I cheat and use a
calculator. Mind isn't what it used to
be decades ago.
You should be able to see how to count
the series, how to present the chart
where you see what is in each of the
slots from 128 to 1. Also how to do
the math for adding and then how to
write that data line. I've seen <and
done> the math to the point where all
the separate three part series were
added up, making it the total for the
line. This doesn't work worth a smeg.
Frells your programme, like you can't
believe. Next thing is to type in the
balloon program and we will go over
the parts.
So type:
NEW
Press RETURN then enter
1 REM UP, UP, AND AWAY
5 PRINT "(CLR/HOME)"
10 V = 53248 : REM START OF DISPLAY
CHIP
11 POKE V + 21,4 : REM ENABLE SPRITE 2
12 POKE 2042,13 : REM SPRITE 2 DATA
FROM BLOCK 13
20 FOR N = 0 TO 62:READ Q:POKE 832+N,Q:
NEXT
30 FOR X = 0 TO 200
40 POKE V + 4,X : REM UPDATE X
COORDINATES
50 POKE V + 5,X : REM UPDATE Y
COORDINATES
60 NEXT X
70 GOTO 30
200 DATA 0,127,0,1,255,192,3,255,224,
3,231,224
210 DATA 7,217,240,7,223,240,7,217,240,
3,231,224
220 DATA 3,255,224,3,255,224,2,255,160,
1,127,64
230 DATA 1,62,64,0,156,128,0,156,128,0,
73,0,0,73,0
240 DATA 0,62,0,0,62,0,0,62,0,0,28,0
Book says "if you typed everything in
correctly" That is an understatement,
I had to type it in a few times and
even now I am not certain I did it
right for you (EDITOR yep its fine).
Then you typed it in and we have more
places that things could go wrong, did
a piece on the pitfalls of type in
programs. DATA statements are one of
them that can frell you, I already
mentioned fonts elsewhere.
Taking that into consideration. If I
typed it in here right, and I did test
and run it before writing the lines
down, rare thing for me to do <BG> If
you typed it correctly from what I
did, then there is a small green hot
air balloon that goes from the upper
left of the screen towards the lower
right. Doesn't make it all the way
though so if that is what you see. You
typed it in right, at this time that
balloon won't go across the screen, to
the other side.
I'm not great enough to tell you how
all of the things and this program
work. In fact those that are clever
enough to know all of these parts,
can't seem to explain it to me easily,
so I guess that makes us both in the
same boat. What I can tell you is only
a few things. Some of that is a
constant refresher on stuff we have
done before.
Line 1 and line 5 we have done before.
A REMark and then clear the screen
Line 10, now this is a new thing for
us, The book doesn't go into a lot of
information. Not supposed to, just a
primer to wet your appetite about
sprites. Or for many of us, confuse
the smeg out of us. <G> Well v=53248
is obviously a variable. The Rem
statement says it is the start of the
display chip. I have heard that also
called the VIC chip. 53248 is the
starting memory location of the
"v"ideo chip hence the V for the
variable name. Notice how close that
number is to the 53280 and 53281 the
locations that we used for border and
screen colour changes?
The book takes us to the following
chart thing. In an attempt to explain
the "picture making locations control
the functions..." Called registers,
these locations in their chart look
like...
Register(s) Description
0 X coordinate of sprite 0
1 Y coordinate of sprite 0
2 - 15 Paired like 0 and 1
for sprites 1-7
16 Most Significant Bit
- X coordinate
21 Sprite appear: 1 = appear
0 = disappear
29 Expand sprite in "X"
Direction
23 Expand sprite in "Y"
Direction
39-46 Sprite 0-7 color
If you see that 23 comes after the 29,
you are right, that is the way it is
listed in the book. I don't know if it
is a book typo or not. Some of the
above may make a little sense to you.
Most of it may not and it also may
seem so alien that you feel you will
never understand it. Many - many of my
members have felt the same thing. A
few have gone past that and made
sprites on their own. I'll tell you
truthfully that they had to have
programs and other informational
sources to complete the task. Also it
is not the scope here to explain about
sprites. Only to present the
information in a personal way from the
book you would have received when you
bought the C=64 new. This book I was
told is online in some form of an
e-text someplace.
EDITOR you can see the book online in
HTML format here
http://www.lemon64.com/manual/
And here as a downloadable plain TEXT
file
http://project64.c64.org/hw/
c64usg10.zip
Disclaimer again, out of the way. I
quote from the book for the next part.
"In addition to this information you
will need to know from which 64 byte
section sprites will get their data
(byte 1 is not used)."
"This data is handled by 8 locations
directly after screen memory:" There
is another chart/box that follows.
+---+----+----+----+----+----+----+---+
2040 2041 2042 2043 2044 2045 2046 2047
+---+----+----+----+----+----+----+---+
^ ^ ^ ^ ^ ^ ^ ^
SPRITE #
0 1 2 3 4 5 6 7
As you can see there are 8 sprite
places in the chart above. Also I'll
point out, that this start number of
2040 is very close to the end of the
Screen Memory Map locations. Anyway
back to the book. Here they next list
the things to create and move the
sprite. [1] is to make the proper
sprite(s) appear on the screen. This
is done "by pokeing into location 21 a
1 for the bit which turns on the
sprite"
Looking back at the program. We can
see this in line 11 where it is poke
v, the 53248 location with that +21
final location.
[2] set the sprite pointer, that is
locations 2040-2047 "to where the
sprite data should be read from." We
see that number appear in line 12.
Along with a REM about it being sprite
2 and the 13th blk.
[3] is to poke the data into memory. I
take that to be all those data
statements.
[4] is using a loop to update X & Y
coordinates to move the sprite around.
Which to my lame brain looks like
lines 30-70. Last part,
[5] states that you can as options,
expand the object, change the colours
and do other functions using location
29 to expand sprite in the X direction
and location 23 in the Y direction. As
their example.
Breaking here for a moment, we will
get back to the sprite stuff, even if
we need to go to the next instalment.
<BG> READ DATA is an important part of
the program here and also in other
programs. I have seen numbers and text
used in these read data lines. There
is a menu for fantasy games at the
tavern that uses the text as the data
part. I'll leave off on that for now,
only wanted to bring the idea to
light.
At line 10 we basically fired up the
video chip for this programme with the
variable v=53248.
line 11 we poked into the v variable
that +21. Looking back at that
register and description chart above,
that says we make the sprite appear.
OK then what the frell does that ,4
mean? Took me a bit to barely
understand it. Because the next
sentence in the book says that this ,4
thing turns on sprite #2. Into
something that is called the "sprite
enable register. Remember there are 8
sprites. Got another chart to present
and I'll try to explain it in a way
that makes sense.
SPRITE ENABLE (LOCATION 21)
Decimal Values of Each Sprite Number
128 64 32 16 8 4 2 1
Sprite Level Numbers
7 6 5 4 3 2 1 0
+----+----+----+---+----+----+----+---+
0 0 0 0 0 1 0 0
+----+----+----+---+----+----+----+---+
^
Put a 1 For The SPRITE You Want
Looks sort of familiar to others that
I have made in this series <G>. What
does it all mean? I coded it a bit to
help. (a) is the decimal value of each
sprite number. Looks familiar to what
we did with the drawing and converting
of the sprite to DATA. (b) is simply
the sprite level number. 7 is under
the 128 as it is the highest number in
the sprites.
OK that 21 at the left of the line of
boxes. That is the 21 part of the
"v+21". Turned on the chip and that 21
says to make the sprite appear. which
of the 8 sprites? Here they chose
sprite #2. As you can see there is a 1
in that box, under the 2. While there
are 0's under the other numbers.
Confusing part for many of my members
is remembering that in this example
the 1 indicates that there is
something there, the 2 is the sprite
number, BUT 4 is the value to use.
That is why there is that =4. Meaning
that v is the variable for the chip
being turned on, 21 is the sprite
shows up thing and the 4 is the value
for the 2nd sprite. Reads as v+21,4.
Yeah it takes a few times through to
catch all of that and feel just a tad
bit comfy.
OK you are wondering if there are 8
sprites. Then how would you activate
more than one. Since this shows how to
do just one. Well, that is taken care
of later on in the book. But as that
is what is asked a lot of me at this
point in the book. There isn't much to
actually change. Put a 1 in the box
under the sprite you want to activate.
Oh yeah you just did that already.
Well lets say you want #3 sprite on as
well. Put a 1 there to indicate you
want that one on too. Now the value of
sprite #3 is 8. Got #2 on at value of
4. #3 on at value of 8. Just like you
did with the rows for the sprite
drawing to data, add up the values of
what you turned on; right that is then
12. turn two sprites on, being 2 & 3.
You write it as v+21,12. All the way
up to 255, if you are going to run all
8 sprites.
Just about out of lines here, Next
session we will continue with this
program. I suggest you save it as it
will be added to along the way. As we
add more sprites and sizes and
colours.
CONTINUED NEXT MONTH..
===